﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UniMana.Data;
namespace UniMana.Data
{
    public static class System_Rule_DepartmentData
    {

        public static IQueryable GetAllowByUserKey(DBMain data, Guid _guiUserKey)
        {
            var result = from p1 in data.m_DCReadOnly.System_Rule_Departments
                         join p2 in data.m_DCReadOnly.Catalogue_Departments on
                         p1.Catalogue_DepartmentKey equals p2.Catalogue_DepartmentKey
                         where p1.System_UserKey == _guiUserKey
                         select new
                         {
                             p1.Catalogue_DepartmentKey
                             ,
                             p2.Name
                             ,
                             p1.System_UserKey
                             ,
                             p1.AllowEdit
                             ,
                             p1.AllowDel
                             ,
                             p1.AllowAdd
                             ,
                             p1.AllowAccess
                             
                         };
            return result;
                         
        }

        public static IQueryable GetNotAllowByUserKey(DBMain data, Guid _guiUserKey)
        {
            var result = from p1 in data.m_DCReadOnly.Catalogue_Departments
                         where !(
                         from p2 in data.m_DCReadOnly.System_Rule_Departments
                         where p2.System_UserKey == _guiUserKey
                         select p2.Catalogue_DepartmentKey
                         ).Contains(p1.Catalogue_DepartmentKey)
                         select p1;

            return result;

        }
       
    }
}
